fix: preserve empty reasoning_content for DeepSeek V4 in non-streaming and streaming paths#24200
Closed
ihoooohi wants to merge 1 commit intoanomalyco:devfrom
Closed
fix: preserve empty reasoning_content for DeepSeek V4 in non-streaming and streaming paths#24200ihoooohi wants to merge 1 commit intoanomalyco:devfrom
ihoooohi wants to merge 1 commit intoanomalyco:devfrom
Conversation
…g and streaming paths
Three truthy checks were dropping empty reasoning_content ('') from DeepSeek
V4's thinking mode responses, causing 'must be passed back to the API' errors
in multi-turn tool call chains:
1. Non-streaming parser: if (reasoning != null && reasoning.length > 0)
-> Now: if (reasoning != null) to preserve empty strings
2. Streaming parser: if (reasoningContent) truthy check
-> Now: if ('reasoning_text' in delta) to detect field presence
3. Outbound converter: if (part.text) reasoningText = part.text
-> Now: reasoningText = part.text ?? '' to preserve empty text
PR anomalyco#24146 fixed the transform.ts path; this completes the remaining cases.
Contributor
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
Wasn't this fixed here too #24146 ? |
Author
|
Yep — #24146 fixed transform.ts, this catches the remaining two parser paths where empty reasoning_content was still dropped before reaching storage. |
Collaborator
|
no this is completely wrong, it literally says github copilot sdk, I have left multiple notes for you and your agent not to touch this code path.... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #24190
Type of change
What does this PR do?
Fixes the remaining cases where empty
reasoning_content(reasoning_content: "") from DeepSeek V4 is discarded, causing "The reasoning_content in the thinking mode must be passed back to the API" errors in multi-turn tool call chains.PR #24146 fixed the
transform.tsoutbound path (removing theif (reasoningText)guard), but three upstream locations still drop empty reasoning_content via truthy checks:openai-compatible-chat-language-model.ts):if (reasoning != null && reasoning.length > 0)drops""— the reasoning part is never created in the stored message.openai-compatible-chat-language-model.ts):if (reasoningContent)drops""— noreasoning-startemitted, so the part is never created.convert-to-openai-compatible-chat-messages.ts):if (part.text)drops""— empty reasoning text lost in outbound construction.Fix:
if (reasoning != null)preserves empty reasoning_text.if ("reasoning_text" in delta)detects field presence; emits reasoning-start, only emits reasoning-delta for non-empty content.reasoningText = part.text ?? ""preserves empty text.How did you verify your code works?
transform.tsby PR fix: preserve empty reasoning_content for DeepSeek V4 thinking mode #24146.Screenshots / recordings
N/A — no UI change.
Checklist